<template>
  <div>
    <!-- 相册管理 -->
    <div class="topName">
      <div style="display: flex; align-items: center">
        <img
          style="width: 20px; height: 18px; margin: 0 10px"
          src="../../../assets/img/3.png"
          alt=""
          :isCollapse="true"
        />
        <el-button type="primary">相册管理</el-button>
      </div>
    </div>

    <div class="manage">
      <div class="text">
        <span></span>
        相册管理
      </div>
      <div class="xian"></div>

      <!-- 封面 -->
      <div class="head">
        <div class="Left">
          <div class="cover">封面</div>
          <div class="all">
            <div class="all_title">
              <span>排屑机</span>
              <span>共15张 </span>
            </div>
            <div class="all_button">
              <el-button
                class="btn"
                type="primary"
                @click="dialogFormVisible = true"
                >编辑</el-button
              >
              <el-button
                class="btn"
                type="primary"
                @click="dialogFormVisible1 = true"
                >上传图片</el-button
              >
            </div>
          </div>
        </div>
        <div class="Right">
          <el-checkbox style="margin: 0 27px 0 0" v-model="checkAll"
            >全选</el-checkbox
          >
          <el-button type="danger" class="btn mb10" style="background: #ff4848">
            批量删除
          </el-button>
          <el-button type="primary" class="btn mb10">回收站</el-button>
        </div>
      </div>

      <!-- 照片列表 -->
      <div class="list_img">
        <div class="list_img_item" v-for="item in list">
          <div class="img_item">
            <el-checkbox style="margin: 2px 10px 0" v-model="item.checked">
            </el-checkbox>
          </div>
          <div class="item_tit">
            <div style="font-size: 14px">图片名称</div>
            <div class="delsTime">
              <span>2023-12-28</span>
              <el-popover placement="bottom" trigger="hover">
                <!-- 展开 收起 -->
                <template #reference>
                  <div class="df">
                    <div class="expand"></div>
                    <div class="expand"></div>
                    <div class="expand"></div>
                  </div>
                </template>
                <div>
                  <div style="border-bottom: 1px solid #ddd">
                    <el-button type="" text>设为封面</el-button>
                  </div>

                  <div><el-button type="" text>删除</el-button></div>
                </div>
              </el-popover>
            </div>
          </div>
        </div>
      </div>

      <!-- 上传图片弹出框 -->
      <el-dialog
        v-model="dialogFormVisible1"
        style="width: 780px; height: 538px"
        draggable
        align-center
        center
        class="t1"
      >
        <div class="title_title">上传图片</div>
        <div class="xian1"></div>
        <el-form :model="form">
          <el-form-item label="选择相册">
            <el-select v-model="form.region" placeholder="请选择相册">
              <el-option label="Zone one" value="shanghai" />
              <el-option label="Zone two" value="beijing" />
            </el-select>
          </el-form-item>

          <el-form-item class="uploadimg">
            <el-upload drag multiple>
              <!-- <el-icon class="el-icon--upload"><upload-filled /></el-icon> -->
              <div class="el-upload__text">
                <el-button type="primary" class="btn">上传图片</el-button>
                <div>将文件拖放到此窗口即可上传</div>
              </div>
              <template #tip>
                <div class="el_text">
                  <div>
                    1. 当上传的图片宽度超过 1000
                    像素时，系统会自动对图片进行等比例压缩
                  </div>
                  <div>2. 图片支持jpg、jpeg、png格式，单张大小不超过10M</div>
                  <div>
                    3.
                    请勿上传、使用带有任何联系方式（如手机、QQ、电话、微信号及微信二维码等）的图片
                  </div>
                </div>
              </template>
            </el-upload>

            <!--  -->
            <div class="illustrate">
              已选择图片5张 还可以选择45张 （拖动可修改顺序）
            </div>

            <!-- 展示图片 -->
            <div class="listImg">
              <div class="list_item" v-for="item in 5">
                <span>
                  <img src="../../../assets/img/36.png" alt="" />
                </span>
                <img src="../../../assets/img/1.png" alt="" />
              </div>
            </div>
          </el-form-item>
        </el-form>
        <template #footer>
          <div class="bottom_btn">
            <el-button
              @click="dialogFormVisible1 = false"
              style="width: 90px; height: 36px"
              >取消</el-button
            >
            <el-button
              type="primary"
              @click="dialogFormVisible1 = false"
              class="btn"
            >
              确定
            </el-button>
          </div>
        </template>
      </el-dialog>

      <!-- 编辑相册弹出框 -->
      <el-dialog
        v-model="dialogFormVisible"
        style="width: 500px; height: 249px"
        draggable
        align-center
        center
        class="t1"
      >
        <div class="title_title">编辑相册</div>
        <div class="xian1"></div>
        <el-form :model="form">
          <el-form-item
            label="相册名称"
            center
            style="margin: 20px 77px 0 47px"
          >
            <el-input
              v-model="form.name"
              autocomplete="off"
              style="width: 280px; height: 36px"
            />
          </el-form-item>
        </el-form>
        <template #footer>
          <span class="dialog-footer">
            <el-button
              @click="dialogFormVisible = false"
              style="width: 90px; height: 36px"
              >取消</el-button
            >
            <el-button
              type="primary"
              @click="dialogFormVisible = false"
              class="btn"
            >
              确定
            </el-button>
          </span>
        </template>
      </el-dialog>
    </div>
  </div>
</template>

<script lang="ts" setup>
import { computed, reactive, toRefs, ref } from "vue";
import top from "../../../components/top/top.vue";
import "../../../assets/css/size.css";

// 弹出框 创建相册
const dialogFormVisible = ref(false);
const dialogFormVisible1 = ref(false);
const form = reactive({
  name: "",
  region: "",
  date1: "",
  date2: "",
  delivery: false,
  type: [],
  resource: "",
  desc: "",
});

// 全选 反选
let state = reactive({
  list: [
    { label: "", value: 1, checked: false },
    { label: "", value: 2, checked: false },
    { label: "", value: 3, checked: false },
    { label: "", value: 4, checked: false },
    { label: "", value: 5, checked: false },
    { label: "", value: 6, checked: false },
    { label: "", value: 7, checked: false },
    { label: "", value: 8, checked: false },
    { label: "", value: 9, checked: false },
    { label: "", value: 10, checked: false },
    { label: "", value: 11, checked: false },
    { label: "", value: 12, checked: false },
    { label: "", value: 13, checked: false },
    { label: "", value: 14, checked: false },
    { label: "", value: 15, checked: false },
    { label: "", value: 16, checked: false },
  ],
});
let { list } = toRefs(state);
let checkAll = computed({
  get() {
    let flag = list.value.map((item) => {
      if (item.checked == false) {
        return false;
      } else {
        return true;
      }
    });
    return !flag.includes(false);
  },

  set(newVal) {
    if (newVal) {
      list.value.map((value, _index, _array) => {
        value.checked = true;
      });
    } else {
      list.value.map((value, _index, _array) => {
        value.checked = false;
      });
    }
  },
});
</script>
<style>
.el-upload-dragger {
  width: 740px;
  height: 120px;
}
</style>
<style lang="scss" scoped>
.manage {
  width: 100.625rem;
  height: 58.125rem;
  background: #ffffff;
  margin-left: 0.625rem;
  overflow: hidden;
  .text {
    font-size: 0.875rem;
    font-family: Source Han Sans CN;
    font-weight: bold;
    display: flex;
    color: #333333;
    margin: 1.875rem 0 -1.875rem 0.625rem;
    span {
      display: block;
      width: 0.25rem;
      height: 0.875rem;
      background: #3091ff;
      opacity: 1;
      border-radius: 0.625rem;
      margin: 0.1875rem 0.625rem 0 2.5rem;
    }
  }
  .xian {
    width: 95.625rem;
    height: 0.0625rem;
    background: #dddddd;
    box-shadow: 0 0.125rem 0.5rem rgba(0, 0, 0, 0.04);
    margin: 4rem 2.5rem 0;
  }

  .head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    //左侧
    .Left {
      margin-left: 2.5rem;
      margin-top: 1.25rem;
      display: flex;
      // 封面
      .cover {
        width: 5rem;
        height: 5rem;
        background: #bfbfbf;
      }
      //排屑机
      .all {
        margin-left: 1.25rem;
        .all_button {
          margin-top: 1.25rem;
        }
      }
    }

    .Right {
      margin-top: 4rem;
      margin-right: 2.5rem;
    }
  }

  //列表
  .list_img {
    margin: 20px 0 0 30px;
    display: flex;
    flex-wrap: wrap;
    .list_img_item {
      width: 180px;
      height: 236px;
      background: #ffffff;
      border: 1px solid #dddddd;
      margin: 6px;
      .img_item {
        width: 180px;
        height: 180px;
        background: #c6c6c6;
      }
      .item_tit {
        justify-content: space-between;
        width: 180px;
        height: 56px;
        padding: 10px;
        // background-color: #3091ff;
        box-sizing: border-box;
        .delsTime {
          display: flex;
          justify-content: space-between;
          font-size: 12px;
          margin-top: 6px;
        }
        .expand {
          width: 4px;
          height: 4px;
          background: #adadad;
          border-radius: 50%;
          margin: 6px 2px 2px 2px;
        }
      }
    }
  }

  .xian1 {
    // width: 500px;
    height: 1px;
    background: #eeeeee;
    opacity: 1;
    border-radius: 0px;
    margin-bottom: 10px;
  }
  .t1 {
    position: relative;
  }
  .title_title {
    width: 64px;
    height: 16px;
    font-size: 16px;
    font-weight: 500;
    line-height: 0px;
    color: #304156;
    position: absolute;
    top: 30px;
    left: 20px;
  }

  .uploadimg {
    width: 740px;
    height: 120px;
  }

  .el_text {
    // width: 486px;
    height: 53px;
    font-size: 12px;
    font-weight: 400;
    color: #abb3c3;
    line-height: 20px;
  }

  // 说明
  .illustrate {
    width: 740px;
    height: 30px;
    background: #ecf4ff;
    opacity: 1;
    border-radius: 0px;
    padding-left: 10px;
    margin-bottom: 20px;
  }

  // 按钮
  .bottom_btn {
    margin-top: 150px;
  }

  // 上传图片列表展示
  .listImg {
    display: flex;
    .list_item {
      width: 60px;
      height: 60px;
      margin: 10px 0 0 20px;
      border: 1px dashed #c4c5c5;
      position: relative;
      span {
        display: block;
        width: 18px;
        height: 18px;
        position: absolute;
        top: -5px;
        right: -10px;
      }
      img {
        width: 100%;
        height: 100%;
      }
    }
  }
}
</style>
